package com.example.demo.controller;

import com.example.demo.dao.User;
import com.example.demo.server.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * Created on 2019/9/22.
 *
 * @author Grak
 * @since 1.0
 */
@RestController
public class RedisController {

    @Autowired
    private RedisService redisService;

    @RequestMapping("/setUser")
    public String setUser(){
        User user=new User("aa@qq.com","quellan","123456","朱",new Date().getTime()+"");
        redisService.setUserBystringRedisTemplate(user);
        return "添加成功";
    }

    @RequestMapping("/getUserByStringRedisTemplate")
    public String  getUserByStringRedisTemplate(){
        String name="quellan";
        return redisService.getUserBystringRedisTemplate(name);
    }

    @RequestMapping("/setString")
    public String setString(String key ,String value){
        redisService.setString(key,value);
        return "添加成功";
    }

    @RequestMapping("/getString")
    public String setString(String key){
        return redisService.getString(key);
    }
}
